import React, { Component } from 'react'
import { withRouter } from 'react-router'
import { Route, Redirect } from 'react-router-dom';
import loginRoutes from '../containers/login/routes';



//这个暂时没有用
@withRouter
class AuthRouter extends Component {
    render() {
        const { component: Component, ...rest } = this.props
        const isLogged = false;
        return null;

        let routeRenders = () => {
            let keyarray = Object.keys(loginRoutes);
            return keyarray.map(function (key, index) {
                let obj = loginRoutes[key];

                let rOptins = {
                    exact: true,
                    key: key,
                    path: obj.path,
                    component: obj.component
                }
                return (
                    <Route {...rOptins}/>
                );
            })
        };

        return [<Route {...rest} render={props => {
            return isLogged
                ? <Component {...props} />
                : <Redirect from="/" to="/n/m/login"/>
        }}/>, ...routeRenders()]
    }
}

export default AuthRouter;